//
//  DZZDetailsViewController.m
//  DZZTravel
//
//  Created by xalo on 16/7/16.
//  Copyright © 2016年 Eason. All rights reserved.
//

#import "DZZDetailsViewController.h"

@interface DZZDetailsViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic,strong)NSMutableArray *dataSource;



@end

@implementation DZZDetailsViewController

- (NSMutableArray *)dataSource{
    if (!_dataSource) {
        _dataSource = [NSMutableArray array];
    }
    return _dataSource;
}

- (void)viewDidLoad {
    [super viewDidLoad];


    
//注册cell
    [self.tableView registerNib:[UINib nibWithNibName:@"DZZAroundCell" bundle:nil] forCellReuseIdentifier:@"DZZAroundCell"];
//    加载数据
    [self loadNumberData];
    
    
}
/*
 
 
 {
 "data": {
 "cateName": "漂流",
 "items": [
 {
 "productId": 23206,
 "productName": "牛仔谷漂流直通车",
 "productDescription": "",
 "productTitle": "牛仔谷漂流位于清远市清新县，是围绕美国西部牛仔文化主题营造的主题式漂流景区。全程约漂流4.3公里，丰富的关卡设计，创意的情境体验，丰富的玩法，险、幽、绿、趣，激爽开怀。",
 "productTitleContent": "牛仔谷漂流直通车学生/成人票1张，美国西部牛仔文化的漂流景区。",
 "mImageUrl": "http://cdn5.yaochufa.com/group1/M00/00/FD/oYYBAFcNsEGAcPpQAABZuPlK-a0475.jpg-scover3",
 "url600x360": "http://cdn5.yaochufa.com/group1/M00/00/FD/oYYBAFcNsEGAcPpQAABZuPlK-a0475.jpg",
 "url": "http://cdn5.yaochufa.com/group1/M00/00/FD/oYYBAFcNsEGAcPpQAABZuPlK-a0475.jpg",
 "retailPrice": 168,
 "price": 69,
 "originalPrice": 168,
 "isNew": false,
 "flag": "",
 "saledCount": 3343,
 "provinceName": "广东",
 "cityName": "清远",
 "scenicList": null,
 "adress": "广东省清远市清新区",
 "coordinate": "112.916621,23.726365",
 "distance": 0,
 "goodRate": "4.423",
 "channelLinkId": 167431,
 "appExtendInfo": {
 "labelText": "门票",
 "bigImageUrl": "http://cdn5.yaochufa.com/group1/M00/00/FD/ooYBAFcNsE2AM5T1AAEcu83vb5E190.jpg",
 "stateText": "",
 "newFlagUrl": ""
 },
 "isReduce": false
 },
 {
 "productId": 18235,
 "productName": "朝天吼漂流门票",
 "productDescription": "",
 "productTitle": "朝天吼漂流位于湖北省宜昌市昭君故里——兴山县境内，宜昌至神农架的的中途，是湖北省“一江两山”黄金旅游干线的重要节点，漂流途经卧佛山、八缎锦、将军柱、红山笋等景观。",
 "productTitleContent": "“一江两山”旅游干线的节点，漂流途经卧佛山、将军柱、红山笋等",
 "mImageUrl": "group1/M00/01/8C/ooYBAFcxjjqAI5ypAAFpGjuqPBQ371.jpg-scover3",
 "url600x360": "group1/M00/01/8C/ooYBAFcxjjqAI5ypAAFpGjuqPBQ371.jpg",
 "url": "group1/M00/01/8C/ooYBAFcxjjqAI5ypAAFpGjuqPBQ371.jpg",
 "retailPrice": 180,
 "price": 110,
 "originalPrice": 180,
 "isNew": false,
 "flag": "http://cdn5.yaochufa.com/images/OfferInfo/b54a3eb8bf574ae492729b206ff065dd.png",
 "saledCount": 1332,
 "provinceName": "湖北",
 "cityName": "宜昌",
 "scenicList": null,
 "adress": "湖北省宜昌市兴山县宝山路附近",
 "coordinate": "110.932748,31.20392",
 "distance": 0,
 "goodRate": "5.000",
 "channelLinkId": 95013,
 "appExtendInfo": {
 "labelText": "门票",
 "bigImageUrl": "group1/M00/01/8D/oYYBAFcxjjyAErx5AAF0p2wg6ag308.jpg",
 "stateText": "可订今日",
 "newFlagUrl": "http://cdn5.yaochufa.com/images/OfferInfo/6f7d25b8c0db4e27a623775b1161cc58.png"
 },
 "isReduce": true
 },
 {
 "productId": 24268,
 "productName": "罗浮山漂流",
 "productDescription": "",
 "productTitle": "罗浮山漂流，涌动山涧，8公里航道，惊喜不断。礁石浅浪中，勇者前行，迎接与水花相击那一瞬间的刺激！回归与自然相搏的原始快乐体验！逐浪而下，行云流水般自在雀跃！",
 "productTitleContent": "在宽旷幽秘的天然氧吧中，欣赏秀丽山水，体验涛浪中搏击的愉悦。",
 "mImageUrl": "http://cdn5.yaochufa.com/group1/M00/02/3F/oYYBAFdeUpuAQSu4AAGRFnAVsmQ422.jpg-scover3",
 "url600x360": "group1/M00/02/3F/oYYBAFdeUpuAQSu4AAGRFnAVsmQ422.jpg",
 "url": "group1/M00/02/3F/oYYBAFdeUpuAQSu4AAGRFnAVsmQ422.jpg",
 "retailPrice": 168,
 "price": 128,
 "originalPrice": 168,
 "isNew": false,
 "flag": "http://cdn5.yaochufa.com/images/OfferInfo/b54a3eb8bf574ae492729b206ff065dd.png",
 "saledCount": 513,
 "provinceName": "四川",
 "cityName": "绵阳",
 "scenicList": null,
 "adress": "晓坝镇五福村姊妹桥",
 "coordinate": "104.31941,31.63974",
 "distance": 0,
 "goodRate": "5.000",
 "channelLinkId": 179214,
 "appExtendInfo": {
 "labelText": "门票",
 "bigImageUrl": "http://cdn5.yaochufa.com/group1/M00/02/3F/oYYBAFdeUp6AUYUQAAE28QaMr08000.jpg",
 "stateText": "",
 "newFlagUrl": "http://cdn5.yaochufa.com/images/OfferInfo/6f7d25b8c0db4e27a623775b1161cc58.png"
 },
 "isReduce": true
 },
 {
 "productId": 16825,
 "productName": "九龙沟漂流门票",
 "productDescription": "",
 "productTitle": "夏天快到来，迎接夏天的方式，不止冰啤和夜宵，准备好了吗？九龙沟和你激情相约，来漂流吧，迎接激情一夏。",
 "productTitleContent": "漂流时间大约是80-120分钟，九龙沟和你激情相约",
 "mImageUrl": "images/AppList320/hl_16825_od_1_4d807f2716674b58b8c0995ed051e351.jpg-scover3",
 "url600x360": "images/AppList320/hl_16825_od_1_4d807f2716674b58b8c0995ed051e351.jpg",
 "url": "images/AppList320/hl_16825_od_1_4d807f2716674b58b8c0995ed051e351.jpg",
 "retailPrice": 138,
 "price": 95,
 "originalPrice": 138,
 "isNew": false,
 "flag": "http://cdn5.yaochufa.com/images/OfferInfo/b54a3eb8bf574ae492729b206ff065dd.png",
 "saledCount": 11392,
 "provinceName": "四川",
 "cityName": "成都",
 "scenicList": null,
 "adress": "四川省成都崇州市三郎镇欢喜村",
 "coordinate": "103.528708,30.810098",
 "distance": 0,
 "goodRate": "4.694",
 "channelLinkId": 77501,
 "appExtendInfo": {
 "labelText": "门票",
 "bigImageUrl": "images/RefinedRecommend/hl_16825_od_1_33352f3ac59e4311b698bb0f400c5760.jpg",
 "stateText": "",
 "newFlagUrl": "http://cdn5.yaochufa.com/images/OfferInfo/6f7d25b8c0db4e27a623775b1161cc58.png"
 },
 "isReduce": true
 },
 {
 "productId": 12236,
 "productName": "黄腾峡漂流门票",
 "productDescription": "",
 "productTitle": "亲水之旅，乐在漂流，到“小九寨”黄腾峡漂流景区度过闲适绿色假日，这里即可感受刺激安全的各种漂流，又能欣赏沿途秀丽风光，犹如在画中游。",
 "productTitleContent": "黄腾峡观景勇士漂成人票1张，可选天然猛士漂/全程勇猛漂套餐。",
 "mImageUrl": "group1/M00/01/24/oYYBAFcW8h-AQsaMAAIDMlBcaNs726.jpg-scover3",
 "url600x360": "group1/M00/01/24/oYYBAFcW8h-AQsaMAAIDMlBcaNs726.jpg",
 "url": "group1/M00/01/24/oYYBAFcW8h-AQsaMAAIDMlBcaNs726.jpg",
 "retailPrice": 198,
 "price": 148,
 "originalPrice": 198,
 "isNew": false,
 "flag": "http://cdn5.yaochufa.com/images/OfferInfo/b54a3eb8bf574ae492729b206ff065dd.png",
 "saledCount": 4963,
 "provinceName": "广东",
 "cityName": "清远",
 "scenicList": null,
 "adress": "广东省清远市清城区171乡道黄腾峡生态旅游区",
 "coordinate": "113.101763,23.769372",
 "distance": 0,
 "goodRate": "4.658",
 "channelLinkId": 68425,
 "appExtendInfo": {
 "labelText": "门票",
 "bigImageUrl": "group1/M00/01/24/ooYBAFcW8h-AeeHJAAFqt4zyT1o988.jpg",
 "stateText": "",
 "newFlagUrl": "http://cdn5.yaochufa.com/images/OfferInfo/6f7d25b8c0db4e27a623775b1161cc58.png"
 },
 "isReduce": true
 },
 {
 "productId": 11725,
 "productName": "阳朔龙颈河漂流门票",
 "productDescription": "",
 "productTitle": "阳朔龙颈河景区漂流门票1张。峡谷漂流、高山探险、森林徒步，齐享刺激与快乐。在激流中搏斗，勾起您原始、感性、真实的回忆。",
 "productTitleContent": "龙颈河勇士漂门票1张，可选专线车套餐。",
 "mImageUrl": "images/AppList320/hl_11725_od_1_eddcf93cec294e0288743c7ad82784e5.jpg-scover3",
 "url600x360": "images/AppList320/hl_11725_od_1_eddcf93cec294e0288743c7ad82784e5.jpg",
 "url": "images/AppList320/hl_11725_od_1_eddcf93cec294e0288743c7ad82784e5.jpg",
 "retailPrice": 150,
 "price": 126,
 "originalPrice": 150,
 "isNew": false,
 "flag": "http://cdn5.yaochufa.com/images/OfferInfo/b54a3eb8bf574ae492729b206ff065dd.png",
 "saledCount": 1545,
 "provinceName": "广西",
 "cityName": "阳朔兴坪",
 "scenicList": null,
 "adress": "广西壮族自治区桂林市阳朔县兴坪大源林场",
 "coordinate": "110.496834,24.78052",
 "distance": 0,
 "goodRate": "5.000",
 "channelLinkId": 72059,
 "appExtendInfo": {
 "labelText": "门票",
 "bigImageUrl": "images/RefinedRecommend/hl_11725_od_1_5e0d3c8430c1475d9685a74d400e3292.jpg",
 "stateText": "可订今日",
 "newFlagUrl": "http://cdn5.yaochufa.com/images/OfferInfo/6f7d25b8c0db4e27a623775b1161cc58.png"
 },
 "isReduce": true
 },
 {
 "productId": 12043,
 "productName": "花都芙蓉峡谷漂流门票",
 "productDescription": "",
 "productTitle": "花都芙蓉峡谷漂流景区是天然大氧气吧，也是天赐漂流胜地，勇士漂全程近5公里。如果你是勇者，就来体验“勇士之漂”，胆色挑战勇士漂，冲破万重浪，感受疾驰而下的痛快。",
 "productTitleContent": "勇士漂全程近5公里，胆色挑战，冲破万重浪，水中魅力，畅爽激荡",
 "mImageUrl": "images/AppList320/hl_12043_od_1_5dc22c7720814fdb8ae0c670b7b9913d.jpg-scover3",
 "url600x360": "images/AppList320/hl_12043_od_1_5dc22c7720814fdb8ae0c670b7b9913d.jpg",
 "url": "images/AppList320/hl_12043_od_1_5dc22c7720814fdb8ae0c670b7b9913d.jpg",
 "retailPrice": 150,
 "price": 79,
 "originalPrice": 150,
 "isNew": false,
 "flag": "http://cdn5.yaochufa.com/images/OfferInfo/b54a3eb8bf574ae492729b206ff065dd.png",
 "saledCount": 786,
 "provinceName": "广东",
 "cityName": "广州",
 "scenicList": null,
 "adress": "广东省广州市花都区芙蓉度假区内芙蓉嶂漂流景区    ",
 "coordinate": "113.244008,23.503043",
 "distance": 0,
 "goodRate": "4.500",
 "channelLinkId": 69112,
 "appExtendInfo": {
 "labelText": "门票",
 "bigImageUrl": "group1/M00/01/55/oYYBAFchmd2AazCQAACaB6tW7Dc398.jpg",
 "stateText": "",
 "newFlagUrl": "http://cdn5.yaochufa.com/images/OfferInfo/6f7d25b8c0db4e27a623775b1161cc58.png"
 },
 "isReduce": true
 },
 {
 "productId": 16587,
 "productName": "武隆仙女峡漂流门票",
 "productDescription": "",
 "productTitle": "原山活水峡谷间，感受河床曲折回旋、浪遏飞舟，经历一场惊险刺激、畅快淋漓、心旷神怡的生态峡谷消暑之旅。",
 "productTitleContent": "武隆仙女峡漂流门票1张，原山活水峡谷间野性漂流之旅",
 "mImageUrl": "images/AppList320/hl_16587_od_1_39cd063a16eb4dd49dd54bb11fb43d5b.jpg-scover3",
 "url600x360": "images/AppList320/hl_16587_od_1_39cd063a16eb4dd49dd54bb11fb43d5b.jpg",
 "url": "images/AppList320/hl_16587_od_1_39cd063a16eb4dd49dd54bb11fb43d5b.jpg",
 "retailPrice": 180,
 "price": 150,
 "originalPrice": 180,
 "isNew": false,
 "flag": "",
 "saledCount": 88,
 "provinceName": "重庆",
 "cityName": "重庆",
 "scenicList": null,
 "adress": "重庆市武隆县城西南乌江二桥",
 "coordinate": "107.716106,29.379271",
 "distance": 0,
 "goodRate": "",
 "channelLinkId": 74784,
 "appExtendInfo": {
 "labelText": "门票",
 "bigImageUrl": "images/RefinedRecommend/hl_16587_od_1_aacacb31d8d74f409006dc1e5bb40730.jpg",
 "stateText": "可订今日",
 "newFlagUrl": ""
 },
 "isReduce": false
 },
 {
 "productId": 18134,
 "productName": "防城港野人谷景区门票",
 "productDescription": "",
 "productTitle": "野人谷是华南地区较大的野战基地，配备完善的设备和专业教练。体验真人版CS，激光野战、彩蛋野战，只有你想不到的，没有野人谷做不到的。",
 "productTitleContent": "华南地区较大的野战基地，配备完善的设备和专业教练。",
 "mImageUrl": "images/AppList320/hl_18134_od_1_4fba5a3681734a09a07ed0f605a60001.jpg-scover3",
 "url600x360": "images/AppList320/hl_18134_od_1_4fba5a3681734a09a07ed0f605a60001.jpg",
 "url": "images/AppList320/hl_18134_od_1_4fba5a3681734a09a07ed0f605a60001.jpg",
 "retailPrice": 68,
 "price": 45,
 "originalPrice": 68,
 "isNew": false,
 "flag": "http://cdn5.yaochufa.com/images/OfferInfo/b54a3eb8bf574ae492729b206ff065dd.png",
 "saledCount": 2540,
 "provinceName": "广西",
 "cityName": "那良镇",
 "scenicList": null,
 "adress": "广西省防城港市防城区那良镇那楼村",
 "coordinate": "107.855958,21.711444",
 "distance": 0,
 "goodRate": "5.000",
 "channelLinkId": 93669,
 "appExtendInfo": {
 "labelText": "门票",
 "bigImageUrl": "images/RefinedRecommend/hl_18134_od_1_d34a06bea084477a893c569ac5cb5590.jpg",
 "stateText": "可订今日",
 "newFlagUrl": "http://cdn5.yaochufa.com/images/OfferInfo/6f7d25b8c0db4e27a623775b1161cc58.png"
 },
 "isReduce": true
 },
 {
 "productId": 24646,
 "productName": "牛背梁漂流（梁老林峡谷漂）",
 "productDescription": "",
 "productTitle": "置身人间仙境般的牛背梁，原老林峡谷漂流，感受高山峡谷中的酣畅漂流。乘皮艇而下，一路山高水长，游鱼可数，百转千回，急流甚箭，如游仙境，来一场心旷神怡的生态峡谷消暑之旅吧。",
 "productTitleContent": "牛背梁漂流门票1张，来一场心旷神怡的生态峡谷消暑之旅。",
 "mImageUrl": "group1/M00/02/FC/ooYBAFeIncKAWDn5AAEb0PEQvOQ093.jpg-scover3",
 "url600x360": "group1/M00/02/FC/ooYBAFeIncKAWDn5AAEb0PEQvOQ093.jpg",
 "url": "group1/M00/02/FC/ooYBAFeIncKAWDn5AAEb0PEQvOQ093.jpg",
 "retailPrice": 90,
 "price": 65,
 "originalPrice": 90,
 "isNew": false,
 "flag": "http://cdn5.yaochufa.com/images/OfferInfo/b54a3eb8bf574ae492729b206ff065dd.png",
 "saledCount": 9,
 "provinceName": "陕西",
 "cityName": "商洛",
 "scenicList": null,
 "adress": "营盘镇朱家湾村",
 "coordinate": "109.002582,33.825054",
 "distance": 0,
 "goodRate": "",
 "channelLinkId": 184121,
 "appExtendInfo": {
 "labelText": "门票",
 "bigImageUrl": "group1/M00/02/F9/oYYBAFeIncaAbr-uAAFEpaEFhWI569.jpg",
 "stateText": "",
 "newFlagUrl": "http://cdn5.yaochufa.com/images/OfferInfo/6f7d25b8c0db4e27a623775b1161cc58.png"
 },
 "isReduce": true
 }
 ],
 "total": 144,
 "recordCount": 144
 },
 "success": true,
 "message": null,
 "statusCode": 200
 }
 
 
 */

//加载数据

- (void)loadNumberData{
    
    NSString *string =  [self.city stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    
    NSArray *cArray = [self.model.appToUrl componentsSeparatedByString:@"/"];
    
    
    [RequestManager fectDataWithUrl:[NSString stringWithFormat:@"http://appapi.yaochufa.com/v2/Product/GetProductList?machineCode=086DA4DD-1FAB-421A-8AC3-3CF9F2718437&system=ios&version=5.2.3&channel=AppStore&longitude=108.90686709447&pageIndex=1&latitude=34.229598020634&type=tag&imei=086DA4DD-1FAB-421A-8AC3-3CF9F2718437&lang=app&sort=n&pageSize=10&city=%@&%@Id=%@",string,cArray[2],cArray[3]] parameter:@{} method:@"GET" compelet:^(NSData *data) {
        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
        for (NSDictionary *dic2 in dic[@"data"][@"items"]) {
            DZZBtnListModel *listModel = [[DZZBtnListModel alloc]init];
            [listModel setValuesForKeysWithDictionary:dic2];
            [self.dataSource addObject:listModel];
        }
        
        
        
    } upDateUI:^{
        
        [self.tableView reloadData];
        
    }];
    
    
    
    
    
}





#pragma mark ------------------------UITableViewDelagate------------------------

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    DZZAroundCell *cell = [tableView dequeueReusableCellWithIdentifier:@"DZZAroundCell" forIndexPath:indexPath];
    
    [cell setCellWithBtnListModel:self.dataSource[indexPath.row]];
    
    
    return cell;
    
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataSource.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 200;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    DZZAroundAndHotController *around = [[DZZAroundAndHotController alloc]initWithNibName:@"DZZAroundAndHotController" bundle:nil];
    DZZBtnListModel *list = self.dataSource[indexPath.row];
    around.pID = list.productId;
    NSLog(@"++++++++++++++++++++++++++++++++++++++++%@",list.productId);
    around.cID = list.channelLinkId;
    NSLog(@"+++++++++++++++++++++++++++++++++++%@",list.channelLinkId);
    
    
    [self.navigationController pushViewController:around animated:YES];
    
}






@end
